package com.future.dao;

import java.sql.Connection;
import java.util.List;

import com.future.model.po.ServicesAnswerModel;

public class ServicesAnswerDAO extends BaseDAO<ServicesAnswerModel> {

	public ServicesAnswerDAO() {

	}

	public ServicesAnswerDAO(Connection conn) {
		super(conn);
	}

	public List<ServicesAnswerModel> findByUserid(Integer userId)
			throws Exception {
		String sql = "select * from services_answer where userid = ? ";
		List<ServicesAnswerModel> list = this.searchAsBeanList(sql,
				ServicesAnswerModel.class, userId);
		if (list.size() < 1) {
			throw new Exception("未找到记录");
		}
		return list;
	}

	public boolean saveServicesAnswer(ServicesAnswerModel servicesAnswer) {
		boolean flag = false;
		String sql = "insert into services_answer (answer,userid,servicesid) values (?,?,?)";
		flag = this.update(sql, servicesAnswer.getAnswer(),
				servicesAnswer.getUserid(), servicesAnswer.getServicesid());
		return flag;
	}

}
